/***************************************************************************
 *   This file is part of KLabeler                                         *
 *   Copyright (C) 2010 by Luca Bellonda                                   *
 *   lbellonda _at_ gmail.com                                              *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/

#ifndef CONFIGURATIONWINDOW_H
#define CONFIGURATIONWINDOW_H

#include <QtGui>
#include <QDialog>
#include <QVector>
#include "KLabelerApplication.h"
#include "tagProfile.h"


namespace Ui
{
class ConfigurationDialog;
}

class ConfigurationWindow : public QDialog
{
    Q_OBJECT
public:
    explicit ConfigurationWindow(klabeler::KLabelerApplication *application, TagProfile *profile, QWidget *parent = 0);
    ~ConfigurationWindow();

    void setupData();

protected:
    void changeEvent(QEvent *e);

signals:

public slots:

    void on_radioActivitiesSet_toggled();
    void on_addActivity_clicked();
    void on_remActivity_clicked();
    void on_activities_itemSelectionChanged();
    void on_chooseTag_editTextChanged(const QString & text);
    void on_addTag_clicked();


    void on_createProfile_clicked();
    void on_deleteProfile_clicked();
    void on_chooseProfile_clicked();
    void on_name_textEdited(const QString &text);
    void on_description_textEdited(const QString &text);
    void on_tagsList_cellChanged(int row, int column);
    void on_tagsList_cellClicked(int row, int column);

private:
    Ui::ConfigurationDialog *ui;
    klabeler::KLabelerApplication *_application;
    QButtonGroup _profileTypeChoice;
    QCompleter  *_tagsCompleter;
    QStringList  _allTags;
    // this acts as a proxy
    TagProfile* _currentProfile ;
    bool _currentProfileModified ;

    void resetData();
    void resetData(QVector<TagProfile*> &profiles);
    QStringList getActivities();
    void loadAllTags();
    bool saveProfile(TagProfile *profile);
    void setProfileData(TagProfile* profile);
    void enableWidgets(const bool how);
    bool loseProfile(const bool isInterruptible);
    void setProfile(TagProfile* profile);
    void updateModel(TagProfile* profile);
    virtual void accept();


};

#endif // CONFIGURATIONWINDOW_H
